package artist.graphic.cn.UI;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import artist.graphic.cn.R;
import artist.graphic.cn.Utils.StatusBarUtil;
import artist.graphic.cn.Utils.ToastShow;


/**
 *
 *
 * @Version 1.0
 *Created by wanghuanlong on 2018/1/18.
 *
 */
public class HTMLActivity extends AppCompatActivity {

    WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        StatusBarUtil.setTransparentForImageView(this,null);
        setContentView(R.layout.activity_html);

        webView= (WebView) findViewById(R.id.webView);



        Bundle bundle = getIntent().getExtras();
        String url=bundle.getString("html");

        if(url!=null&& !url.equals("")){
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setAppCacheEnabled(true);
            //设置 缓存模式
            webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
            // 开启 DOM storage API 功能
            webView.getSettings().setDomStorageEnabled(true);

            webView.setWebViewClient(new WebViewClient() {
                //覆盖shouldOverrideUrlLoading 方法,防止利用系统自带的浏览器打开页面
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);
                    return true;
                }
            });

            webView.loadUrl(url);
        }else{

            Toast.makeText(this,"参数传递出错:HTMLActivity",Toast.LENGTH_SHORT).show();
        }

    }
}
